package cn.cdeden.knowledge.domain;

import cn.cdeden.knowledge.domain.dto.EnterprisePermDto;
import cn.cdeden.system.api.domain.enums.EnterprisePermTypeEnum;
import cn.cdeden.system.api.domain.vo.RemoteEnterprisePermVo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import org.jetbrains.annotations.NotNull;

/**
 * 企业可访问者表
 */
@Data
@TableName(value = "enterprise_perm")
@AutoMappers({@AutoMapper(target = RemoteEnterprisePermVo.class),@AutoMapper(target = EnterprisePermDto.class)})
public class EnterprisePerm implements Serializable,Comparable<EnterprisePerm> {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 文件或者文件夹id
     */
    @TableField(value = "tree_node_id")
    private Long treeNodeId;

    /**
     * 权限类型
     */
    @TableField(value = "`type`")
    private Integer type;

    /**
     * id
     */
    @TableField(value = "type_id")
    private Long typeId;

    /**
     * 名称
     */
    @TableField(value = "type_name")
    private String typeName;

    /**
     * 下载
     */
    @TableField(value = "download")
    private Integer download;

    /**
     * 编辑
     */
    @TableField(value = "editor")
    private Integer editor;

    /**
     * 打印
     */
    @TableField(value = "`print`")
    private Integer print;

    /**
     * 预览
     */
    @TableField(value = "preview")
    private Integer preview;

    /**
     * 上传
     */
    @TableField(value = "upload")
    private Integer upload;

    /**
     * 新建
     */
    @TableField(value = "new_built")
    private Integer newBuilt;

    /**
     * 删除
     */
    @TableField(value = "remove")
    private Integer remove;

    /**
     * 查询
     */
    @TableField(value = "query")
    private Integer query;

    /**
     * 复制
     */
    @TableField(value = "`copy`")
    private Integer copy;

    /**
     * 移动
     */
    @TableField(value = "`move`")
    private Integer move;

    /**
     * 重命名
     */
    @TableField(value = "rechristen")
    private Integer rechristen;

    /**
     * 创建编号
     */
    @TableField(value = "create_id")
    private String createId;

    /**
     * 创建者
     */
    @TableField(value = "create_by")
    private String createBy;

    /**
     * 创建日期
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 更新编号
     */
    @TableField(value = "update_id")
    private String updateId;

    /**
     * 更新者
     */
    @TableField(value = "update_by")
    private String updateBy;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 权限角色id
     */
    @TableField(value = "role_id")
    private Long roleId;

    /**
     * 管理
     */
    @TableField(value = "manage")
    private Integer manage;

    /**
     * 参数
     */
    @TableField(value = "params")
    private String params;

    /**
     * 父id
     */
    @TableField(value = "parent_tree_node_id")
    private Long parentTreeNodeId;

    /**
     * 是否继承
     */
    @TableField(value = "is_extend")
    private Integer isExtend;

    @Override
    public int compareTo(@NotNull EnterprisePerm o) {
        EnterprisePermTypeEnum permTypeEnum = EnterprisePermTypeEnum.getPermTypeEnum(o.getParams());
        EnterprisePermTypeEnum ownPermTypeEnum = EnterprisePermTypeEnum.getPermTypeEnum(this.getParams());
        return ownPermTypeEnum.getPermRank().compareTo(permTypeEnum.getPermRank());
    }
}
